package com.ruoyi.estate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.estate.service.IBusinessFloorService;
import io.swagger.models.auth.In;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.estate.domain.BuildingRoom;
import com.ruoyi.estate.service.IBuildingRoomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房屋管理Controller
 * 
 * @author 博雅
 * @date 2023-12-19
 */
@RestController
@RequestMapping("/estate/room")
public class BuildingRoomController extends BaseController
{
    @Autowired
    private IBuildingRoomService buildingRoomService;
    @Autowired
    private IBusinessFloorService businessFloorService;

    /**
     * 查询房屋管理列表
     * 1111111111111111111
     */
    @PreAuthorize("@ss.hasPermi('estate:room:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuildingRoom buildingRoom)
    {
        startPage();
        List<BuildingRoom> list = buildingRoomService.selectBuildingRoomList(buildingRoom);
        return getDataTable(list);
    }

    /**
     * 导出房屋管理列表
     */
    @PreAuthorize("@ss.hasPermi('estate:room:export')")
    @Log(title = "房屋管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuildingRoom buildingRoom)
    {
        List<BuildingRoom> list = buildingRoomService.selectBuildingRoomList(buildingRoom);
        ExcelUtil<BuildingRoom> util = new ExcelUtil<BuildingRoom>(BuildingRoom.class);
        util.exportExcel(response, list, "房屋管理数据");
    }

    /**
     * 获取房屋管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('estate:room:query')")
    @GetMapping(value = "/{roomId}")
    public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
    {
        return success(buildingRoomService.selectBuildingRoomByRoomId(roomId));
    }

    /**
     * 新增房屋管理
     */
    @PreAuthorize("@ss.hasPermi('estate:room:add')")
    @Log(title = "房屋管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuildingRoom buildingRoom)
    {
        return toAjax(buildingRoomService.insertBuildingRoom(buildingRoom));
    }

    /**
     * 修改房屋管理
     */
    @PreAuthorize("@ss.hasPermi('estate:room:edit')")
    @Log(title = "房屋管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuildingRoom buildingRoom)
    {
        return toAjax(buildingRoomService.updateBuildingRoom(buildingRoom));
    }

    /**
     * 删除房屋管理
     */
    @PreAuthorize("@ss.hasPermi('estate:room:remove')")
    @Log(title = "房屋管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomIds}")
    public AjaxResult remove(@PathVariable Long[] roomIds)
    {
        return toAjax(buildingRoomService.deleteBuildingRoomByRoomIds(roomIds));
    }
    /**
     * 房屋信息新增
     */
    /**
     * 房屋信息查询
     */
    /**
     * 房屋信息修改
     */
    /**
     * 房屋信息删除
     */
/**
 * dadAD d
 */

}
